<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <a-col :span="24">
            <a-form-model-item label="员工id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeId">
              <a-input :disabled=formDisabled v-model="model.employeeId" placeholder="请输入员工id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="单据id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="billId">
              <a-input :disabled=formDisabled v-model="model.billId" placeholder="请输入单据id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="人员编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeNo">
              <a-input :disabled=formDisabled v-model="model.employeeNo" placeholder="请输入人员编号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gender">
              <a-input :disabled=formDisabled v-model="model.gender" placeholder="请输入性别"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="岗位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="posistionId">
              <a-input :disabled=formDisabled v-model="model.posistionId" placeholder="请输入岗位"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="入职时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partTime">
              <j-date :disabled=formDisabled placeholder="请选择入职时间" v-model="model.partTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="试用期满时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="endTime">
              <j-date :disabled=formDisabled placeholder="请选择试用期满时间" v-model="model.endTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="评测内容" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="evaluating">
              <a-input :disabled=formDisabled v-model="model.evaluating" placeholder="请输入评测内容"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="评测结果" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="evaluatingResult">
              <a-input :disabled=formDisabled v-model="model.evaluatingResult" placeholder="请输入评测结果"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="评测人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="evaluatingEmployee">
              <a-input :disabled=formDisabled v-model="model.evaluatingEmployee" placeholder="请输入评测人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="评测时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="evaluatingTime">
              <j-date :disabled=formDisabled placeholder="请选择评测时间" v-model="model.evaluatingTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="试用期评价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="evaluationPeriod">
              <a-input :disabled=formDisabled v-model="model.evaluationPeriod" placeholder="请输入试用期评价"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="需改进事项" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="needingImprovement">
              <a-input :disabled=formDisabled v-model="model.needingImprovement" placeholder="请输入需改进事项"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment">
              <a-input :disabled=formDisabled v-model="model.attachment" placeholder="请输入附件"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'ErpHrEmployeeRegularDetailForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/api/erp/hr/regular/erpHrEmployeeRegularDetail/add",
          edit: "/api/erp/hr/regular/erpHrEmployeeRegularDetail/edit",
          queryById: "/api/erp/hr/regular/erpHrEmployeeRegularDetail/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.$refs.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
